package com.generator.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.generator.entity.TemplateConfig;
import com.generator.service.TemplateConfigService;
import com.generator.service.TemplateGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author tanghc
 */
@RestController
@RequestMapping("/generator/templateconfig")
public class TemplateConfigController {

    @Autowired
    private TemplateConfigService templateConfigService;

    @Autowired
    private TemplateGroupService templateGroupService;


    @RequestMapping("/get/{id}")
    public ResponseEntity get(@PathVariable("id") int id) {
        return ResponseEntity.ok(templateConfigService.getById(id));
    }

    @RequestMapping("/list")
    public ResponseEntity list(Page page, TemplateConfig templateConfig) {
        return templateConfigService.list(page,templateConfig);
    }

    @DeleteMapping("/del")
    public ResponseEntity del(@RequestBody List<Integer> ids) {
        templateConfigService.del(ids);
        return ResponseEntity.ok().build();
    }

    @RequestMapping("/save")
    public ResponseEntity save(@RequestBody TemplateConfig templateConfig) {
        templateConfigService.save(templateConfig);
        return ResponseEntity.ok().build();
    }

    @RequestMapping("/copy")
    public ResponseEntity copy(@RequestBody TemplateConfig templateConfig) {
        templateConfigService.copy(templateConfig);
        return ResponseEntity.ok().build();
    }

}
